package org.wishwork.api.aftersale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wishwork.api.aftersale.receive.query.AfterSaleReceivedQueryApi;
import org.wishwork.api.aftersale.receive.query.AfterSaleReceivedQueryRequest;
import org.wishwork.api.aftersale.receive.query.AfterSaleReceivedQueryResponse;
import org.wishwork.api.aftersale.receive.upload.AfterSaleReceiveUploadApi;
import org.wishwork.api.aftersale.receive.upload.AfterSaleReceiveUploadResponse;
import org.wishwork.api.aftersale.receive.upload.request.AfterSaleReceiveUploadRequest;
import org.wishwork.api.aftersale.refund.RefundQueryApi;
import org.wishwork.api.aftersale.refund.RefundQueryRequest;
import org.wishwork.api.aftersale.refund.response.RefundQueryResponse;
import org.wishwork.api.aftersale.upload.AfterSaleUploadApi;
import org.wishwork.api.aftersale.upload.AfterSaleUploadResponse;
import org.wishwork.api.aftersale.upload.request.AfterSaleUploadRequest;
import org.wishwork.context.Context;

import java.util.List;

/**
 * @description: 售后API
 * @author: WangYX
 * @create: 2022-04-12 15:11
 * @Version: 1.0.0
 **/
public class AfterSaleApi {

    private static final Logger log = LoggerFactory.getLogger(AfterSaleApi.class);

    private Context context;

    private final AfterSaleReceiveUploadApi afterSaleReceiveUploadApi;

    private final AfterSaleReceivedQueryApi afterSaleReceivedQueryApi;

    private final AfterSaleUploadApi afterSaleUploadApi;

    private final RefundQueryApi refundQueryApi;

    public AfterSaleApi(Context context) {
        this.context = context;
        this.afterSaleReceiveUploadApi = new AfterSaleReceiveUploadApi(context);
        this.afterSaleReceivedQueryApi = new AfterSaleReceivedQueryApi(context);
        this.afterSaleUploadApi = new AfterSaleUploadApi(context);
        this.refundQueryApi = new RefundQueryApi(context);
    }

    /**
     * 实际收货上传
     *
     * @param afterSaleReceiveUploadRequests
     * @return
     * @throws Exception
     */
    public AfterSaleReceiveUploadResponse receiveUpload(List<AfterSaleReceiveUploadRequest> afterSaleReceiveUploadRequests) throws Exception {
        return this.afterSaleReceiveUploadApi.business(afterSaleReceiveUploadRequests);
    }

    /**
     * 实际收货查询
     *
     * @param afterSaleReceivedQueryRequest
     * @return
     * @throws Exception
     */
    public List<AfterSaleReceivedQueryResponse> receivedQuery(AfterSaleReceivedQueryRequest afterSaleReceivedQueryRequest) throws Exception {
        return this.afterSaleReceivedQueryApi.business(afterSaleReceivedQueryRequest);
    }

    /**
     * 售后上传
     *
     * @param afterSaleUploadRequests
     * @return
     * @throws Exception
     */
    public List<AfterSaleUploadResponse> upload(List<AfterSaleUploadRequest> afterSaleUploadRequests) throws Exception {
        return this.afterSaleUploadApi.business(afterSaleUploadRequests);
    }

    /**
     * 退货退款查询
     *
     * @param refundQueryRequest
     * @return
     * @throws Exception
     */
    public List<RefundQueryResponse> refund(RefundQueryRequest refundQueryRequest) throws Exception {
        return this.refundQueryApi.business(refundQueryRequest);
    }
}
